
import admin.jms.resources.AdminJMSResources as adminJMSLocal
#import admin.sib.resources.AdminSIBResources as adminSIBLocal
import admin.servers.AdminServers as serverAdmin
import admin.datasources.resources.AdminDSResources as adminDS
#import admin.security.JAAS.AdminJAASAuthData as adminJaas

nodeContext = '/Node:CRI400WP_Node2'

jdbcJDBCProviders = [
                     ['/Server:SEC3Server643', 'DB2 UDB for iSeries Provider Only (Toolbox)', 'DB2 UDB for iSeries (Toolbox)']
                    ] 

jdbcDatasources = [
                   ['/Server:SEC3Server643', 'DB2 UDB for iSeries (Toolbox)', 'wasDBBCOSV', 'jdbc/wasDBBCOSV', None, 'BCOCYFILES', [['maxConnections', 10]], 'DB2 UDB for iSeries (Toolbox) DataSource', 'BCORRHERNA', 'credo4e4e']
                  ]

listenerPorts = [
                 [nodeContext, 'SEC3Server643', 'ListenerPort', 'jms/localQCFListener', 'jms/outputQueue', 100, 0, 1, 'START'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPort', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortCR', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortGT', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortHN', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortNI', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortPA', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortSV', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortUS', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSServicePublisherListenerPortCO', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP'],
                 [nodeContext, 'SEC3Server643', 'JMSGroupMessageServiceListenerPortCR', 'jms/localCVQCFListener', 'jms/outputQueue', 1, 0, 1, 'STOP']
                ]

MQQCFResources = [
                  [#Binding resources
                  ],
                  [#Client resources
                   [nodeContext, 'LSVBA1SRV', 'jms/LSVBA1SRV', 'LSVBA1SRV', [['maxConnections', '100'], ['minConnections', '13'], ['connectionTimeout', '180']], [['maxConnections', '110'], ['minConnections', '1'], ['connectionTimeout', '180']], '10.106.1.2', '1425', 'SYSTEM.DEF.SVRCONN'],
                   [nodeContext, 'SAL400D', 'jms/SAL400D', 'SAL400D', [['maxConnections', '100'], ['minConnections', '13'], ['connectionTimeout', '180']], [['maxConnections', '110'], ['minConnections', '1'], ['connectionTimeout', '180']], '10.106.1.2', '1425', 'SYSTEM.DEF.SVRCONN']
                  ]
                 ] 

MQQueueResources = [
                    ['/Server:SEC3Server643', 'inputQueue', 'jms/inputQueue', 'CNISBE.CA.RESPONSE', 'true'],
                    ['/Server:SEC3Server643', 'outputQueue', 'jms/outputQueue', 'LRGSA.SEC.CONSULTA', 'true'],
                    ['/Server:SEC3Server643', 'CL.LSVBA.SRV.CONSULTA', 'jms/CL.LSVBA.SRV.CONSULTA', 'CL.LSVBA.SRV.CONSULTA', 'false'],
                    ['/Server:SEC3Server643', 'CL.LSVBA.SRV.TRANSACCION', 'jms/CL.LSVBA.SRV.TRANSACCION', 'CL.LSVBA.SRV.TRANSACCION', 'false'],
                    ['/Server:SEC3Server643', 'CL.LSVBA.SRV.TRANSACCION.TEF', 'jms/CL.LSVBA.SRV.TRANSACCION.TEF', 'CL.LSVBA.SRV.TRANSACCION', 'false'],
                    ['/Server:SEC3Server643', 'CL.LSVBA.SRV.TRANSACCION.BATCH', 'jms/CL.LSVBA.SRV.TRANSACCION.BATCH', 'CL.LSVBA.SRV.TRANSACCION.BATCH', 'false'],
                    ['/Server:SEC3Server643', 'CL.LSVFT.SRV.TRANSFERENCIA', 'jms/CL.LSVFT.SRV.TRANSFERENCIA', 'CL.LSVFT.SRV.TRANSFERENCIA', 'false'],
                    ['/Server:SEC3Server643', 'CL.LSVBA.SRV.CONSULTA.FRM3', 'jms/CL.LSVBA.SRV.CONSULTA.FRM3', 'CL.LSVBA.SRV.CONSULTA.FRM3', 'false'],
                    ['/Server:SEC3Server643', 'BCO.SV.SAL400D.SRV.RESPUESTA', 'jms/BCO.SV.SAL400D.SRV.RESPUESTA', 'PRUEBA.SAL400D', 'false'],
                    ['/Server:SEC3Server643', 'BCO.SV.LSVBA1SRV.SRV.RESPUESTA', 'jms/BCO.SV.LSVBA1SRV.SRV.RESPUESTA', 'PRUEBA.LSVBA1SRV', 'false']
                   ]


##JDBC Providers
for jdbcProvider in jdbcJDBCProviders:
    adminDS.createDB2JDBCProvider(jdbcProvider[0], jdbcProvider[1], jdbcProvider[2])

##JDBC Datasources
for jdbcDatasource in jdbcDatasources:
    adminDS.createDB2Datasource(jdbcDatasource[0], jdbcDatasource[1], jdbcDatasource[2], jdbcDatasource[3], jdbcDatasource[4], jdbcDatasource[5], jdbcDatasource[6], jdbcDatasource[7], jdbcDatasource[8], jdbcDatasource[9])

##ListenerPorts
for listenerPort in listenerPorts:
    serverAdmin.createListenerPort(listenerPort[0], listenerPort[1], listenerPort[2], listenerPort[3], listenerPort[4], listenerPort[5], listenerPort[6], listenerPort[7], listenerPort[8])

##MQQCFs
for mQQCFBindingResource in MQQCFResources[0]:
    adminJMSLocal.createBindingsMQQueueConnectionFactory(mQQCFBindingResource[0], mQQCFBindingResource[1], mQQCFBindingResource[2], mQQCFBindingResource[3], mQQCFBindingResource[4], mQQCFBindingResource[5])

for mQQCFClientResource in MQQCFResources[1]:
    adminJMSLocal.createClientMQQueueConnectionFactory(mQQCFClientResource[0], mQQCFClientResource[1], mQQCFClientResource[2], mQQCFClientResource[3], mQQCFClientResource[4], mQQCFClientResource[5], mQQCFClientResource[6], mQQCFClientResource[7], mQQCFClientResource[8])

##MQQueues
for mQQueueResource in MQQueueResources:
    adminJMSLocal.createMQQueue(mQQueueResource[0], mQQueueResource[1], mQQueueResource[2], mQQueueResource[3], mQQueueResource[4])


######### Saving configuration ############
print "     Saving configuration."
AdminConfig.save()
print "     Done."